package ETL

import (
	"database/sql"
	"time"
)

type (
	Return struct {
		Sql          string
		TimeOut      int64
		InsideResult any
		Result       any
	}
)
type ExecSqlInputS struct {
	Ss           any
	DBType       string
	Event        string
	GisValFunc   func(any) any
	SelectSqlStr string
	UpdateSqlStr []string
	InsertSqlStr []*string
	Expect       string
	ShardName    string
}
type SqlFilter struct {
	WhereSql string
	WhereAdd string
}
type Options struct {
	Scn      string
	StopTime time.Duration
	//Esa                 EncryptionProperties
	WhereSql            string
	WhereAdd            string
	SqlMode             bool
	TablePx             string
	FixRows             int64
	LowerCaseTableNames bool
	SqlLogBin           bool //是否忽略binlog
	RowsLimit           int
	SqlFilter           SqlFilter
	RepairMethod        string //应用sql修复方式
}
type newExecSqlS struct {
	DB      *sql.DB
	options Options
}

//func newExecSelectSql(e ExecSqlInputS) (timeout int64, res any, err error) {
//	var (
//		x     newExecSqlS
//		event = "[newExecSelectSql]"
//	)
//	if x, err = newGetExecSqlData(e.Ss); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	if len(e.ShardName) == 0 {
//		e.ShardName = "single"
//	}
//	x.options.StopTime = 0
//	active := InstanceActiveS{DBType: DBType, DB: x.DB, FixRows: x.options.FixRows, GisValFunc: e.GisValFunc, StopTime: x.options.StopTime, SqlMode: true}
//	if active.DB == nil {
//		err = ref.ErrAddPrintf(event, errors.New(fmt.Sprintf("db connection is nil.")))
//		return
//	}
//	if timeout, res, err = active.SqlQuery(e.SelectSqlStr, e.Expect); err != nil {
//		err = ref.ErrAddPrintf(event, err)
//		return
//	}
//	return
//}
//func forExecQuerySql(event string, parameter any, Expect string, execSql []string) (result global.Return, err error) {
//	defer func() {
//		if err != nil {
//			err = ref.ErrAddPrintf("forExecQuerySql", err)
//		}
//	}()
//	for _, v := range execSql {
//		result.Sql = v
//		if result.TimeOut, result.Result, err = newExecSelectSql(ExecSqlInputS{
//			Ss:           parameter,
//			Event:        event,
//			SelectSqlStr: result.Sql,
//			Expect:       Expect,
//			GisValFunc:   QueryColValManage,
//		}); err != nil || result.Result == nil {
//			continue
//		} else {
//			return
//		}
//	}
//	return
//}
